<template>
	<view style="margin-bottom:10rpx;" v-if="show && is_open">
		<!-- <item :mydata="mydata" :load='load'></item> -->
		<view class="" v-for="(item, i) in mydata" :key="i">
			<titleBar v-if="item.template_type == 'titleBar'" :mydata="item"></titleBar>
			<shangpinzu @loadsucess="loadsucess" :ref="id" v-if="item.template_type == 'shangpinzu'" :mydata="item"></shangpinzu>
		</view>
	</view>
</template>

<script>
import http from '@/common/http.js';
// import item from './components/item.vue'
import titleBar from './components/titleBar.vue';
import shangpinzu from './components/shangpinzu.vue';
import {mapState} from 'vuex';
export default {
	data() {
		return {
			mydata: [],
			showPage: [],
			show: false,
			id: this.$u.guid(),
			is_open: 0
		};
	},
	props: {
		load: {
			type: Boolean,
			default: false
		},
		page_id: {
			type: String,
			default: ''
		}
	},
	components: {
		titleBar,
		shangpinzu
	},
	computed: {
		...mapState({
			isTouchPage: state => state.isTouchPage
		})
	},
	created() {
		// this.$store.commit('settouch', 'Reset');
		// this.getData();
	},
	methods: {
		loadsucess(i) {
			this.$emit('loadsucess', i);
		},
		init(resetUp) {
			if (this.mydata.length > 0) {
				if (!this.is_open) {
					this.loadsucess(1);
				} else {
					if (this.$refs[this.id] && this.show) {
						this.$refs[this.id][0].getShopData(resetUp);
					}
				}
			} else {
				this.getData();
			}
		},
		// 获取商品配置
		getData() {
			http('/renovation/getRecommendConfig', {}, 'get').then(res => {
				
				
				if(res.data.msg){
					let data = res.data.msg.content;
					this.mydata = data.label;
					this.showPage = data.showPage;
					this.is_open = data.is_open;
					this.gettabs();
				}else{
					this.loadsucess(1);
				}
				
			});
		},
		gettabs() {
			let _this = this;
			if (this.showPage.findIndex(_ => _ == this.page_id) > -1) {
				this.show = true;
				this.$nextTick(function() {
					if (_this.$refs[this.id]) {
						_this.$refs[this.id][0].getShopData();
					}
				});
			} else {
				this.show = false;
				this.loadsucess(1);
				// this.$emit('loadsucess', 0);
			}
		}
	}
};
</script>

<style scoped lang="scss"></style>
